using System;
using System.Globalization;
using iPhOwa.Exchange.Attributes;
using iPhOwa.Exchange.ContentClasses.Fields;

namespace iPhOwa.Exchange.ContentClasses
{
	/// <summary>
	/// Represents the appointment content class.
	/// </summary>
	[ExchangeContentClass(ContentClassNames.Appointment)]
	public class Appointment : Item
	{
		/// <summary>
		/// The message subject.
		/// </summary>
		[ExchangeField(MessageFields.Subject)]
		public override string Subject { get; set; }

		/// <summary>
		/// Normalized subject (no re: or fw:)
		/// </summary>
		[ExchangeField(MessageFields.NormalizedSubject)]
		public string NormalizedSubject { get; set; }

		/// <summary>
		/// Indicates whether  this event an all day event.
		/// </summary>
		[ExchangeField(AppointmentFields.AllDayEvent)]
		public bool AllDayEvent { get; set; }

		/// <summary>
		/// The start date and time of the event.
		/// </summary>
		[ExchangeField(AppointmentFields.DateStart)]
		public DateTime DateStart { get; set; }

		/// <summary>
		/// The end date and time of the event.
		/// </summary>
		[ExchangeField(AppointmentFields.DateEnd)]
		public DateTime DateEnd { get; set; }

		/// <summary>
		/// The location of the event.
		/// </summary>
		[ExchangeField(AppointmentFields.Location)]
		public string Location { get; set; }

		/// <summary>
		/// The Text content of the message.
		/// </summary>
		[ExchangeField(MessageFields.TextDescription)]
		public string TextDescription { get; set; }

		/// <summary>
		/// Friendly display of start time.
		/// </summary>
		public string DisplayStartTime
		{
			get { return (AllDayEvent) ? "All Day" : DateStart.ToShortTimeString(); }
		}

		/// <summary>
		/// Friendly display of end time.
		/// </summary>
		public string DisplayEndTime
		{
			get { return (AllDayEvent) ? string.Empty : DateEnd.ToShortTimeString(); }
		}

		/// <summary>
		/// Friendly display of start date and time.
		/// </summary>
		public string DisplayStartDateTime
		{
			get { return DateStart.ToString("MMMM d, yyyy h:mm tt", CultureInfo.CurrentUICulture); }
		}

		/// <summary>
		/// Friendly display of end date and time.
		/// </summary>
		public string DisplayEndDateTime
		{
			get { return DateEnd.ToString("MMMM d, yyyy h:mm tt", CultureInfo.CurrentUICulture); }
		}

		/// <summary>
		/// Path to the icon.
		/// </summary>
		public override string IconPath
		{
			get { return "~/Images/icon-appt.gif"; }
		}
	}
}